package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.appmgt.dto.CommonCodeappRemovedDTO;
import com.insigma.business.qrcode.appmgt.dto.request.CommonCodeappRemovedInsertRequest;
import com.insigma.business.qrcode.appmgt.dto.request.CommonCodeappRemovedSearchRequest;
import com.insigma.business.qrcode.appmgt.dto.request.CommonCodeappRemovedUpdateRequest;
import com.insigma.business.qrcode.appmgt.dto.search.CommonCodeappRemovedSearch;
import com.insigma.business.qrcode.appmgt.entity.CommonCodeappRemovedEntity;
import org.springframework.beans.BeanUtils;

import java.util.List;

public class CommonCodeappRemovedProviderConverter extends AbstractConverter<CommonCodeappRemovedDTO,CommonCodeappRemovedEntity>{
    private final static CommonCodeappRemovedProviderConverter commonCodeappRemovedProviderConverter = new CommonCodeappRemovedProviderConverter();

    private  CommonCodeappRemovedProviderConverter(){}

    public static CommonCodeappRemovedSearch convertRequestSO2Searcher(CommonCodeappRemovedSearchRequest request) {
        final CommonCodeappRemovedSearch commonCodeappRemovedSearch = new CommonCodeappRemovedSearch(request.getPageNo(),
                request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonCodeappRemovedSearch);
        return commonCodeappRemovedSearch;
    }

    public static List<CommonCodeappRemovedDTO> convertResponseDOList2DTOList(List<CommonCodeappRemovedEntity> commonCodeappRemovedEntityList) {
        return commonCodeappRemovedProviderConverter.convertGenericResponseDOList2DTOList(commonCodeappRemovedEntityList);
    }

    public static CommonCodeappRemovedEntity convertRequestIO2DO(CommonCodeappRemovedInsertRequest request) {
        final CommonCodeappRemovedEntity commonCodeappRemovedEntity = new CommonCodeappRemovedEntity();
        BeanUtils.copyProperties(request,commonCodeappRemovedEntity);
        return commonCodeappRemovedEntity;
    }

    public static CommonCodeappRemovedDTO convertResponseDO2DTO(CommonCodeappRemovedEntity commonCodeappRemovedEntity) {
        return commonCodeappRemovedProviderConverter.convertGenericResponseDO2DTO(commonCodeappRemovedEntity);
    }

    public static CommonCodeappRemovedEntity convertRequestUO2DO(CommonCodeappRemovedUpdateRequest updateRequest) {
        final CommonCodeappRemovedEntity commonCodeappRemovedEntity = new CommonCodeappRemovedEntity();
        BeanUtils.copyProperties(updateRequest,commonCodeappRemovedEntity);
        return commonCodeappRemovedEntity;
    }

    @Override
    protected CommonCodeappRemovedDTO doConvertResponseDO2DTO(CommonCodeappRemovedEntity commonCodeappRemovedEntity) {
        final CommonCodeappRemovedDTO commonCodeappRemovedDTO = new CommonCodeappRemovedDTO();
        try {
            BeanUtils.copyProperties(commonCodeappRemovedEntity, commonCodeappRemovedDTO);
        }catch(RuntimeException be){

            return null;
        }
        return commonCodeappRemovedDTO;
    }
}
